﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Text;

namespace Acoris.Content
{
    /// <summary>
    /// 表示一个分页文件夹
    /// </summary>
    public sealed class ContentFolder:ICollection<ContentSection>
    {
        private ObservableCollection<ContentSection> _sectionCollection;

        public ContentFolder()
        {
            _sectionCollection = new ObservableCollection<ContentSection>();
        }

        #region Property

        /// <summary>
        /// 获取或设置当前分页文件夹的名称
        /// </summary>
        public string FolderName { get; set; }

        /// <summary>
        /// 获取当前文件夹中分页的数量
        /// </summary>
        public int Count { get => ((ICollection<ContentSection>)this._sectionCollection).Count; }

        /// <summary>
        /// 
        /// </summary>
        public bool IsReadOnly { get => ((ICollection<ContentSection>)this._sectionCollection).IsReadOnly; }

        #endregion


        #region Override 

        /// <summary>
        /// 获取当前分页文件夹的友好名称
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            return this.FolderName;
        }

        #endregion

        #region ICollection<ContentSection> 接口成员


        public IEnumerator<ContentSection> GetEnumerator()
        {
            return ((IEnumerable<ContentSection>)this._sectionCollection).GetEnumerator();
        }

        IEnumerator IEnumerable.GetEnumerator()
        {
            return ((IEnumerable<ContentSection>)this._sectionCollection).GetEnumerator();
        }

        public void Add(ContentSection item)
        {
            ((ICollection<ContentSection>)this._sectionCollection).Add(item);
        }

        public void Clear()
        {
            ((ICollection<ContentSection>)this._sectionCollection).Clear();
        }

        public bool Contains(ContentSection item)
        {
            return ((ICollection<ContentSection>)this._sectionCollection).Contains(item);
        }

        public void CopyTo(ContentSection[] array, int arrayIndex)
        {
            ((ICollection<ContentSection>)this._sectionCollection).CopyTo(array, arrayIndex);
        }

        public bool Remove(ContentSection item)
        {
            return ((ICollection<ContentSection>)this._sectionCollection).Remove(item);
        }

        #endregion
    }
}
